
package Threadpack;
import java.lang.*;
class P extends Thread
{
	public void run()
	{
		for (int i=1;i<=5;i++)
		{
			System.out.println("Thread P STARTED I:***********"+i);
		}
		System.out.println("Exit From Thread P ");
	}
}

class Q extends Thread
{
	public void run()
	{
		for (int j=1;j<=5;j++)
		{
			System.out.println("*From Thread Q J:"+j);
		    
		}
		System.out.println("Exit From Thread Q ");
	}
}

class R extends Thread
{
	public void run()
	{
		for (int k=1;k<=5;k++)
		{
			System.out.println("From Thread R K:"+k);
		}
		System.out.println("Exit From Thread R ");
	}
}


public class Thread3
{
	public static void main(String[] args)
    {
       P trd1 = new P();
       Q trd2 = new Q();
       R trd3 = new R();
       
       trd3.setPriority(Thread.MAX_PRIORITY);
       trd1.setPriority(Thread.MIN_PRIORITY);
       trd2.setPriority(trd1.getPriority()+3);

       
       
       System.out.println("Starting thread P");
       trd1.start();
       System.out.println("Starting thread Q");
       trd2.start();
       System.out.println("Starting thread R");
       trd3.start();
      
    }
}
